package service

import (
	"github.com/gin-gonic/gin"
	"micro-chat/internal/model"
	"micro-chat/internal/request"
	"net/http"
)

func AddMoments(c *gin.Context) {

	var req request.AddMomentsForm

	if err := c.ShouldBindJSON(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    100000,
			"message": "验证失败",
		})
		return
	}

	var moment model.Moments

	moment = model.Moments{
		UserId:    req.UserId,
		Content:   req.Content,
		Location:  req.Location,
		LikeCount: 0,
	}

	err := moment.AddMoment()
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    100000,
			"message": "发布失败",
			"data":    err.Error(),
		})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"code":    http.StatusOK,
		"message": "发布成功",
		"data":    moment.Id,
	})

}

func FindMoments(c *gin.Context) {

}

func AddMomentsList(c *gin.Context) {

}
